import { stateType } from "./store";

export type actionType = {
  type: string;
  payload?: any;
};

function listReducer(state: stateType[], action: actionType) {
  switch (action.type) {
    case "add":
      state.push(action.payload);
      return [...state];
    case "delete":
      return state.filter((item) => item.id != action.payload);
    default:
      return state;
  }
}

export default listReducer;
